

<%@ page import="estoquefacil.Venda" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'venda.label', default: 'Venda')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${vendaInstance}">
            <div class="errors">
                <g:renderErrors bean="${vendaInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <g:hiddenField name="id" value="${vendaInstance?.id}" />
                <g:hiddenField name="version" value="${vendaInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="cliente"><g:message code="venda.cliente.label" default="Cliente" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'cliente', 'errors')}">
                                    <g:select name="cliente.id" from="${estoquefacil.Cliente.list()}" optionKey="id" value="${vendaInstance?.cliente?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="dataDeRealizacao"><g:message code="venda.dataDeRealizacao.label" default="Data De Realizacao" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'dataDeRealizacao', 'errors')}">
                                    <g:datePicker name="dataDeRealizacao" precision="day" value="${vendaInstance?.dataDeRealizacao}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="estado"><g:message code="venda.estado.label" default="Estado" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'estado', 'errors')}">
                                    <g:select name="estado" from="${estoquefacil.Venda$ESTADO_DA_VENDA?.values()}" keys="${estoquefacil.Venda$ESTADO_DA_VENDA?.values()*.name()}" value="${vendaInstance?.estado?.name()}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="funcionario"><g:message code="venda.funcionario.label" default="Funcionario" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'funcionario', 'errors')}">
                                    <g:select name="funcionario.id" from="${estoquefacil.Funcionario.list()}" optionKey="id" value="${vendaInstance?.funcionario?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="itensDeVenda"><g:message code="venda.itensDeVenda.label" default="Itens De Venda" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'itensDeVenda', 'errors')}">
                                    
<ul>
<g:each in="${vendaInstance?.itensDeVenda?}" var="i">
    <li><g:link controller="itemDeVenda" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="itemDeVenda" action="create" params="['venda.id': vendaInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'itemDeVenda.label', default: 'ItemDeVenda')])}</g:link>

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="nomeComprador"><g:message code="venda.nomeComprador.label" default="Nome Comprador" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'nomeComprador', 'errors')}">
                                    <g:textField name="nomeComprador" value="${vendaInstance?.nomeComprador}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="pagamento"><g:message code="venda.pagamento.label" default="Pagamento" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'pagamento', 'errors')}">
                                    <g:select name="pagamento" from="${estoquefacil.Venda$FORMA_PAGAMENTO?.values()}" keys="${estoquefacil.Venda$FORMA_PAGAMENTO?.values()*.name()}" value="${vendaInstance?.pagamento?.name()}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="valorDaVenda"><g:message code="venda.valorDaVenda.label" default="Valor Da Venda" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: vendaInstance, field: 'valorDaVenda', 'errors')}">
                                    <g:textField name="valorDaVenda" value="${fieldValue(bean: vendaInstance, field: 'valorDaVenda')}" />
                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
